<!DOCTYPE html>
<html>
<head>
    <title></title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="优惠券名称"/>
                </i-col>
                <i-button @click="query">查询</i-button>
            </div>
            <div class="buttons-group">
                #if($shiro.hasPermission("coupon:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("coupon:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("coupon:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
            <!--#if($shiro.hasPermission("coupon:publish"))-->
            <!--<i-button type="primary" @click="publish">-->
            <!--<Icon type="android-send"></Icon>-->
            <!--</i>&nbsp;发放-->
            <!--</i-button>-->
            <!--#end-->
        </Row>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <Card v-show="showCard">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="coupon" :rules="ruleValidate" :label-width="120">
            <Form-item label="优惠券名称" prop="name">
                <i-input v-model="coupon.name" placeholder="优惠券名称" style="width: 240px"/>
            </Form-item>
            <Form-item label="优惠类型" prop="couponTypeId">
                <Radio-group v-model="coupon.couponTypeId">
                    <Radio :label="1">
                        <span>满减</span>
                    </Radio>
                    <Radio :label="2">
                        <span>折扣</span>
                    </Radio>
                    <Radio :label="3">
                        <span>指定商品满减</span>
                    </Radio>
<!--                    <Radio :label="5">-->
<!--                        <span>每满多少减多少</span>-->
<!--                    </Radio>-->

                </Radio-group>
            </Form-item>

<!--            <Form-item label="选择指定商品" v-if="coupon.couponTypeId==4">-->
<!--                <i-select :model.sync="selectedAssignGoods" @on-change="handleGoodsChange"style="width:350px">-->
<!--                    <i-option v-for="item in assignGoods" :value="item.id">{{ item.name }}</i-option>-->
<!--                </i-select>-->
<!--            </Form-item>-->

            <Form-item v-if="coupon.couponTypeId==3" label="下发商品">
                <i-select v-model="goods" filterable multiple>
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}</i-option>
                </i-select>
            </Form-item>

            <Form-item label="折扣比例(小数)" prop="typeMoney" v-if="coupon.couponTypeId==2">
                <Input-number type="number" :min="0" v-model="coupon.discount" placeholder="折扣比例" style="width: 188px;"/>
            </Form-item>

            <Form-item label="优惠券面额" prop="typeMoney" v-if="coupon.couponTypeId!=2">
                <Input-number type="number" :min="0" v-model="coupon.typeMoney" placeholder="优惠券面额" style="width: 188px;"/>
            </Form-item>
            <Form-item label="发放方式" prop="sendType">
                <Radio-group v-model="coupon.sendType">
                    <Radio :label="0">
                        <span>按订单发放</span>
                    </Radio>
                    <Radio :label="1">
                        <span>按用户发放</span>
                    </Radio>
<!--                    <Radio label="2">-->
<!--                        <span>商品转发送券</span>-->
<!--                    </Radio>-->
<!--                    <Radio :label="3">-->
<!--                    <span>按指定商品发放</span>-->
<!--                    </Radio>-->
                    <Radio :label="4">
                        <span>新用户优惠</span>
                    </Radio>
<!--                    <Radio label="5">-->
<!--                    <span>线下发放</span>-->
<!--                    </Radio>-->
<!--                    <Radio label="7">-->
<!--                        <span>包邮优惠</span>-->
<!--                    </Radio>-->
                </Radio-group>
            </Form-item>

            <Form-item label="最小金额" prop="minAmount" v-if="coupon.couponTypeId!=2">
                <Input-number :min="0" v-model="coupon.minAmount" placeholder="最小金额" style="width: 188px;"/>
            </Form-item>
            <Form-item label="最大金额" prop="maxAmount" v-if="coupon.couponTypeId!=2">
                <Input-number :min="0" v-model="coupon.maxAmount" placeholder="最大金额" style="width: 188px;"/>
            </Form-item>

            <Form-item label="优惠券有效期" prop="validityType">
                <Radio-group v-model="coupon.validityType">
                    <Radio :label="1">
                        <span>领取之日起</span>
                    </Radio>
                    <Radio :label="2">
                        <span>固定时间</span>
                    </Radio>
                </Radio-group>
            </Form-item>

            <Form-item label="有效期天数" prop="validityDays" v-if="coupon.validityType==1">
                <Input-number :min="0" v-model="coupon.validityDays" placeholder="天数" style="width: 188px;"/>
            </Form-item>
<!--            <Form-item label="发放开始时间" prop="sendStartDate">-->
<!--                <Date-picker v-model="coupon.sendStartDate" placeholder="发放开始时间" ></Date-picker>-->
<!--            </Form-item>-->
<!--            <Form-item label="发放结束时间" prop="sendEndDate">-->
<!--                <Date-picker v-model="coupon.sendEndDate" placeholder="发放结束时间" ></Date-picker>-->
<!--            </Form-item>-->
            <Form-item label="使用开始时间" prop="useStartDate" v-if="coupon.validityType==2">
                <Date-picker v-model="coupon.useStartDate" type="datetime"  @on-change="handleStartTimeChange" format="yyyy-MM-dd HH:mm:ss" placeholder="使用开始时间"></Date-picker>
            </Form-item>
            <Form-item label="使用结束时间" prop="useEndDate" v-if="coupon.validityType==2">
                <Date-picker v-model="coupon.useEndDate" type="datetime"  placeholder="使用结束时间" @on-change="handleEndTimeChange" format="yyyy-MM-dd HH:mm:ss"></Date-picker>
            </Form-item>

<!--            <Form-item label="发放活动截止时间" prop="activeEndDate" >-->
<!--                <Date-picker v-model="coupon.activeEndDate"  placeholder="发放活动截止时间" @on-change="handleEndTimeChange" format="yyyy-MM-dd HH:mm:ss"></Date-picker>-->
<!--            </Form-item>-->
            <Form-item label="优惠活动时间" prop="useStartDate" >
                <Date-picker v-model="coupon.activityStartDate"  @on-change="handleActivityStartDate" format="yyyy-MM-dd HH:mm:ss" placeholder="活动开始时间"></Date-picker>  --
                <Date-picker v-model="coupon.activityEndDate"  placeholder="活动结束时间" @on-change="handleActivityEndDate" format="yyyy-MM-dd HH:mm:ss"></Date-picker>
            </Form-item>

            <Form-item label="小程序端是否显示" prop="isShow">
                <Radio-group v-model="coupon.isShow">
                    <Radio :label="0">
                        <span>显示</span>
                    </Radio>
                    <Radio :label="1">
                        <span>不显示</span>
                    </Radio>
                </Radio-group>
            </Form-item>

            <Form-item label="最小商品金额" prop="minGoodsAmount">
                <Input-number :min="0" v-model="coupon.minGoodsAmount" placeholder="最小商品金额" style="width: 188px;"/>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>
                返回</i-button>
                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
    </Card>
    <Card id="sendDiv" v-show="showGoods">
        <i-form :label-width="100">
            <Form-item v-if="selectData.sendType == 3" label="下发商品">
                <i-select v-model="goods" filterable multiple>
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}</i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="selectData.sendType == 1 " label="下发会员">
                <i-select v-model="user" filterable multiple>
                    <i-option v-for="user in users" :value="user.id" :key="user.id">{{user.username}}</i-option>
                </i-select>
            </Form-item>
            <Form-item v-if="selectData.sendType == 1" label="短信通知">
                <Checkbox v-model="sendSms">发送短信</Checkbox>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="publishSubmit">提交</i-button>
                <i-button type="warning" @click="reload"/>
                返回</i-button>
            </Form-item>
        </i-form>
    </Card>
</div>

<script src="${rc.contextPath}/js/shop/coupon.js?_${date.systemTime}"></script>
</body>
</html>